120 - Stack of flapjacks (Ad-hoc)
[and.git] / 575 - Skew Binary / 575.2.cpp
blob1f23185d44a72b7706ccc05868fc85e6f934f4e0
1 /*
2 Problem: 575 - Skew simmetry (UVa)
3 Author: Andrés Mejía-Posada
4 (http://blogaritmo.factorcomun.org)
6 */
8 using namespace std;
9 #include <algorithm>
10 #include <iostream>
11 #include <iterator>
12 #include <sstream>
13 #include <fstream>
14 #include <cassert>
15 #include <climits>
16 #include <cstdlib>
17 #include <cstring>
18 #include <string>
19 #include <cstdio>
20 #include <vector>
21 #include <cmath>
22 #include <queue>
23 #include <deque>
24 #include <stack>
25 #include <map>
26 #include <set>
28 #define D(x) cout << #x " is " << x << endl
30 int main(){
32 string s;
33 while (cin >> s && s != "0"){
34 reverse(s.begin(), s.end());
35 int ans = 0;
37 for (int i=0, b=1; i<s.size(); ++i, b = 2*b+1){
38 ans += (s[i] - '0')*b;
41 cout << ans << endl;
44 return 0;